var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/functionalComponent/base-help/base.tsx
var base_exports = {};
__export(base_exports, {
  BaseHelp: () => BaseHelp,
  HelpContext: () => import_baseContent.HelpContext
});
module.exports = __toCommonJS(base_exports);
var import_icons = require("@ant-design/icons");
var import_antd = require("antd");
var import_zh_CN = __toESM(require("antd/lib/locale/zh_CN"));
var import_react = __toESM(require("react"));
var import_client = require("react-dom/client");
var import_baseComponent = require("../../baseComponent");
var import_message = require("../antd/message");
var import_util = require("../../util");
var import_Button = require("../antd/Button");
var import_modal = require("../modal");
var import_baseContent = require("./baseContent");
var import_index = require("./index.less");
var import_locale = require("./locale");
var timeout;
var iconStyle = {
  zIndex: 2,
  fontSize: 12,
  display: "flex"
};
function fetch(request, callback, delay = 0) {
  const asyncFn = async function() {
    const result = await request();
    callback(result.record ?? result.list ?? [], result.total ?? result.totalRows ?? 0);
  };
  if (delay > 0) {
    if (timeout) {
      clearTimeout(timeout);
      timeout = null;
    }
    timeout = setTimeout(asyncFn, delay);
  } else {
    asyncFn().then(() => {
    });
  }
}
function contentFactory(request, HelpContent, helpRef) {
  var _a, _b;
  const tmpParams = ((_a = helpRef.current) == null ? void 0 : _a.contentParams) || {};
  const defaultColumns = [
    {
      dataIndex: import_util.iup.isFunction(tmpParams.valueField) ? "code" : tmpParams.valueField,
      title: import_locale.helpLocale.code
    },
    {
      dataIndex: import_util.iup.isFunction(tmpParams.labelField) ? "name" : tmpParams.labelField,
      title: import_locale.helpLocale.name
    }
  ];
  const providerValue = {
    observer: (_b = helpRef.current) == null ? void 0 : _b.observer,
    close: async () => {
      var _a2, _b2;
      const valid = await ((_a2 = tmpParams.onCancel) == null ? void 0 : _a2.call(tmpParams));
      if (valid === false) {
        return;
      }
      return (_b2 = helpRef.current) == null ? void 0 : _b2.close("cancel", null);
    },
    ok: async (result) => {
      var _a2, _b2, _c;
      const valid = await ((_a2 = tmpParams.onOk) == null ? void 0 : _a2.call(tmpParams, result));
      if (valid === false) {
        return;
      }
      if (result === void 0 && tmpParams.allowSelectedEmpty) {
        const emptyValue = tmpParams.multiple ? [] : result;
        helpRef.current.setValue(emptyValue);
        return (_b2 = helpRef.current) == null ? void 0 : _b2.close("ok", emptyValue);
      }
      if (import_util.iup.isObject(result) || import_util.iup.isArray(result)) {
        helpRef.current.setValue(result);
        return (_c = helpRef.current) == null ? void 0 : _c.close("ok", result);
      } else {
        if (result !== false) {
          import_message.message.warning({
            content: result || import_locale.helpLocale.noSelected,
            key: "help_message_key"
          });
        }
      }
    },
    contentParams: {
      FilterTree: null,
      columns: defaultColumns,
      getFieldValue(r, type = "value") {
        const field = type === "label" ? tmpParams.labelField : tmpParams.valueField;
        if (import_util.iup.isFunction(field)) {
          return field(r);
        }
        if (!r.hasOwnProperty(field)) {
          import_util.iup.debug({ msg: `当前配置的 ${type}Field 为 ${field}，数据源中未匹配到该属性！`, type: "error" });
        }
        return r[field];
      },
      ...tmpParams
    },
    request,
    locale: import_locale.helpLocale,
    randomKey: Math.random().toString(32).slice(2)
  };
  return /* @__PURE__ */ import_react.default.createElement(import_antd.ConfigProvider, { locale: import_zh_CN.default }, /* @__PURE__ */ import_react.default.createElement(import_baseContent.HelpContext.Provider, { value: providerValue }, HelpContent ? import_util.iup.isReactElement(HelpContent) ? HelpContent : /* @__PURE__ */ import_react.default.createElement(HelpContent, null) : /* @__PURE__ */ import_react.default.createElement(import_baseContent.BaseContent, null)));
}
function initState({ request, data }) {
  return {
    options: request ? [] : data || [],
    total: 0,
    loading: false,
    firstLoad: true,
    query: {
      keyword: "",
      pageIndex: 1,
      pageSize: 8
    }
  };
}
function DropdownRender({ menu, pageChange, state }) {
  return /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, { spinning: state.loading, size: "small" }, /* @__PURE__ */ import_react.default.createElement("div", null, menu), state.total > state.options.length && /* @__PURE__ */ import_react.default.createElement(
    import_antd.Pagination,
    {
      size: "small",
      total: state.total,
      current: state.query.pageIndex,
      style: {
        display: "flex",
        flexWrap: "nowrap",
        whiteSpace: "nowrap",
        padding: "5px 12px",
        borderTop: "1px solid #f5f5f5"
      },
      showSizeChanger: false,
      hideOnSinglePage: true,
      showQuickJumper: true,
      showLessItems: true,
      showTotal: (totalCount) => `共${totalCount}条`,
      onChange: pageChange,
      pageSize: state.query.pageSize
    }
  ));
}
function OpenHelpIcon({
  request,
  outRef,
  helpContent,
  modalProps,
  selectedRequest,
  onBeforeOpen,
  style,
  contentParams,
  buttonMode
}) {
  const helpId = contentParams == null ? void 0 : contentParams.helpId;
  const helpRef = (0, import_react.useRef)({
    observer: new import_util.Observer(),
    contentParams,
    helpInfo: null,
    modalInstance: null,
    setValue: (value) => {
      var _a, _b, _c, _d;
      return (_d = (_c = (_b = (_a = outRef.current) == null ? void 0 : _a.getApi) == null ? void 0 : _b.call(_a)) == null ? void 0 : _c.setValue) == null ? void 0 : _d.call(_c, value);
    },
    close(type = "cancel", result) {
      var _a, _b;
      if ((_a = helpRef.current) == null ? void 0 : _a.modalInstance) {
        helpRef.current.afterCloseParams = { type, helpId, result };
        helpRef.current.modalInstance.destroy();
        helpRef.current.modalInstance = null;
        if (type === "cancel") {
          (_b = modalProps == null ? void 0 : modalProps.onCancel) == null ? void 0 : _b.call(modalProps);
        }
      }
    }
  });
  const [loading, setLoading] = (0, import_react.useState)(false);
  const showModalEx = async () => {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    setLoading(true);
    if (onBeforeOpen) {
      helpRef.current.helpInfo = await onBeforeOpen();
      setLoading(false);
      if (helpRef.current.helpInfo === false) {
        return;
      }
    } else {
      setLoading(false);
    }
    contentParams.value = (_d = (_c = (_b = (_a = outRef.current).getApi) == null ? void 0 : _b.call(_a)) == null ? void 0 : _c.getValue) == null ? void 0 : _d.call(_c);
    if (contentParams.multiple) {
      const origin = (_f = (_e = outRef.current.getApi()) == null ? void 0 : _e.getOrigin) == null ? void 0 : _f.call(_e);
      if (origin == null ? void 0 : origin.length) {
        contentParams.selectedArray = origin;
      } else if (((_g = contentParams.value) == null ? void 0 : _g.length) && import_util.iup.isFunction(selectedRequest)) {
        try {
          contentParams.selectedArray = await selectedRequest({ codes: contentParams.value.join() });
        } catch (e) {
          contentParams.selectedArray = [];
        }
      } else {
        contentParams.selectedArray = [];
      }
    } else {
      contentParams.selectedArray = void 0;
    }
    helpRef.current.contentParams = { ...contentParams, ...helpRef.current.helpInfo };
    const { width, height } = (0, import_util.getGlobalConfig)().default.helpConfig;
    helpRef.current.modalInstance = (0, import_modal.showModal)({
      width,
      height,
      ...modalProps,
      className: "help-container",
      icon: null,
      footer: false,
      content: contentFactory(((_h = helpRef.current.helpInfo) == null ? void 0 : _h.request) || request, helpContent, helpRef),
      afterClose() {
        var _a2, _b2;
        (_a2 = buttonMode == null ? void 0 : buttonMode.onResult) == null ? void 0 : _a2.call(buttonMode, helpRef.current.afterCloseParams);
        helpRef.current.observer.notify(helpRef.current.afterCloseParams, "afterClose").then();
        helpRef.current.afterCloseParams = null;
        (_b2 = modalProps == null ? void 0 : modalProps.afterClose) == null ? void 0 : _b2.call(modalProps);
      }
    });
    helpRef.current.modalInstance.subscribe(() => {
      helpRef.current.observer.notify(helpRef.current.afterCloseParams, "beforeDestroy").then();
    }, "beforeDestroy");
    await helpRef.current.observer.notify({ helpId }, "afterOpen");
  };
  const open = async function(e) {
    if (loading) {
      return;
    }
    import_util.iup.stopPropagation(e);
    if (!helpRef.current.modalInstance) {
      await showModalEx();
    }
  };
  (0, import_util.useIUPEffect)(
    () => {
      var _a;
      helpRef.current.helpInfo = null;
      (_a = helpRef.current) == null ? void 0 : _a.close("cancel");
    },
    [onBeforeOpen, request, helpId],
    false
  );
  (0, import_util.useIUPEffect)(() => {
    outRef.current.openHelp = open;
    outRef.current.closeHelp = () => {
      var _a;
      (_a = helpRef.current) == null ? void 0 : _a.close("cancel", null);
    };
    outRef.current.getHelper = () => {
      return helpRef.current;
    };
  });
  if (buttonMode) {
    const { text, onResult, children, ...btnProps } = buttonMode;
    return /* @__PURE__ */ import_react.default.createElement(import_Button.Button, { onClick: open, ...btnProps }, text || children);
  }
  return /* @__PURE__ */ import_react.default.createElement("span", { style }, loading ? /* @__PURE__ */ import_react.default.createElement(import_icons.LoadingOutlined, null) : /* @__PURE__ */ import_react.default.createElement(import_icons.SearchOutlined, { onClick: open }));
}
var BaseHelp = (props) => {
  const {
    buttonMode,
    acceptInput = false,
    nowrap = false,
    input = true,
    modal = false,
    multiple = false,
    tooltip,
    disabled = false,
    helpContent = null,
    valueField,
    labelField,
    getHelpInfo,
    userCodeFieldWithLabel = true,
    userCodeField: defaultUserCodeField,
    outRef,
    onBeforeOpen,
    placeholder,
    onChange,
    modalProps,
    selectedRequest,
    data,
    request,
    contentParams,
    id,
    loadByFocus,
    style,
    onDoubleClick,
    onDropdownVisibleChange,
    onOpenChange,
    allowSelectedEmpty,
    isTree,
    ...others
  } = props;
  const getValue = (r, type = "value") => {
    const { valueField: vf, labelField: lf } = { valueField, labelField, ...getHelpInfo == null ? void 0 : getHelpInfo() };
    const v = type === "label" ? lf : vf;
    return import_util.iup.isFunction(v) ? v(r) : r[v || "code"];
  };
  const innerRef = (0, import_react.useRef)({
    lockOpen: false,
    open: others.open,
    tmpOpen: void 0,
    lastInput: "",
    focus: false,
    loaded: false
  });
  const ref = (0, import_react.useMemo)(() => outRef ?? import_react.default.createRef(), [outRef]);
  const [state, setState] = (0, import_react.useState)(initState(props));
  const dataRequest = (0, import_react.useMemo)(() => {
    const req = request ? request : data ? ({ keyword }) => {
      return keyword ? data.filter(
        (d) => (getValue(d) + "").indexOf(keyword) > -1 || (getValue(d, "label") + "").indexOf(keyword) > -1
      ) : data;
    } : () => [];
    state.options = [];
    return async (query) => {
      const result = await req(query);
      if (import_util.iup.isArray(result)) {
        return { total: result.length, record: result };
      } else if (import_util.iup.isObject(result)) {
        return result;
      } else {
        return { total: 0, record: [] };
      }
    };
  }, [data, request]);
  (0, import_react.useLayoutEffect)(() => {
    if (!buttonMode) {
      ref.current.searchKeyWord = (params) => dataRequest({ pageSize: 8, pageIndex: 1, ...params });
      setState(initState(props));
    }
  }, [dataRequest]);
  const openChangeCallback = (0, import_util.useRefCallback)((open, type = "modal") => {
    onOpenChange == null ? void 0 : onOpenChange(open, type);
  });
  (0, import_react.useEffect)(() => {
    var _a;
    if ((_a = ref.current) == null ? void 0 : _a.getHelper) {
      const un1 = ref.current.getHelper().observer.subscribe(() => {
        innerRef.current.lockOpen = true;
        openChangeCallback(true);
      }, "afterOpen");
      const un2 = ref.current.getHelper().observer.subscribe(() => {
        innerRef.current.lockOpen = false;
        openChangeCallback(false);
      }, "afterClose");
      return () => {
        un1();
        un2();
      };
    }
  }, [openChangeCallback]);
  (0, import_react.useEffect)(() => {
    if (!innerRef.current.lockOpen && innerRef.current.tmpOpen !== void 0) {
      openChangeCallback(innerRef.current.tmpOpen, "dropdown");
      innerRef.current.tmpOpen = void 0;
    }
  }, [openChangeCallback, state.options]);
  const newProps = {
    allowClear: true,
    ...others,
    showSearch: input,
    filterOption: false,
    ref,
    placeholder,
    disabled,
    optionLabelProp: "label",
    style: { width: "100%", maxHeight: "100%", ...style },
    onChange: function(value, opt) {
      if (onChange) {
        if (value && opt && opt["data-origin"]) {
          onChange({ origin: opt["data-origin"], ...value });
        } else {
          onChange(value);
        }
      }
      if (multiple && newProps.maxTagCount === "responsive") {
        Promise.resolve().then(() => {
          var _a, _b, _c;
          (_c = (_b = (_a = ref.current) == null ? void 0 : _a.getApi()) == null ? void 0 : _b.focus) == null ? void 0 : _c.call(_b);
        });
      }
    },
    onDropdownVisibleChange: (open) => {
      innerRef.current.open = open;
      onDropdownVisibleChange == null ? void 0 : onDropdownVisibleChange(open);
      if (!innerRef.current.lockOpen) {
        if (state.options.length > 0) {
          openChangeCallback(open, "dropdown");
        } else {
          innerRef.current.tmpOpen = open;
        }
      }
    }
  };
  if (!buttonMode) {
    const loadData = async function({ keyword, pageIndex, pageSize }, delay, check = false) {
      if (check && onBeforeOpen) {
        setState((prevState) => ({ ...prevState, loading: true }));
        if (await onBeforeOpen(true) === false) {
          setState((prevState) => ({ ...prevState, loading: false }));
          return;
        }
      }
      innerRef.current.loaded = false;
      const query = {
        keyword: keyword ?? state.query.keyword,
        pageIndex: pageIndex ?? state.query.pageIndex,
        pageSize: pageSize ?? state.query.pageSize,
        isInputSearch: true
      };
      setState((prevState) => ({ ...prevState, loading: true, firstLoad: false, query }));
      fetch(
        () => dataRequest(query),
        (options, total) => {
          innerRef.current.loaded = true;
          setState((prevState) => ({
            ...prevState,
            options,
            loading: false,
            total
          }));
        },
        delay
      );
    };
    if (onDoubleClick) {
      newProps.onDoubleClick = (e) => {
        onDoubleClick(e, ref.current);
      };
    }
    if (loadByFocus) {
      newProps.onFocus = async (e) => {
        if (state.firstLoad) {
          loadData({ keyword: "", pageIndex: 1 }, 0, true);
        }
      };
    }
    if (input) {
      newProps.onSearch = function(keyword) {
        const inputValue = innerRef.current.lastInput;
        keyword = keyword.replace(/'/g, "");
        innerRef.current.lastInput = keyword;
        if (!keyword && !loadByFocus || !innerRef.current.open) {
          if (!keyword && acceptInput) {
            Promise.resolve().then(() => {
              var _a, _b, _c;
              (_c = (_b = (_a = ref.current) == null ? void 0 : _a.getApi()) == null ? void 0 : _b.setValue) == null ? void 0 : _c.call(_b, { value: inputValue, label: inputValue });
            });
          }
          return;
        }
        loadData({ keyword, pageIndex: 1 }, 200, true);
      };
    }
    if (input || loadByFocus) {
      newProps.dropdownRender = (menu) => /* @__PURE__ */ import_react.default.createElement(
        DropdownRender,
        {
          pageChange: (pageIndex, pageSize) => loadData({ pageIndex, pageSize }, 0),
          state,
          menu
        }
      );
    }
    if (multiple) {
      newProps.mode = "multiple";
      newProps.maxTagCount = newProps.hasOwnProperty("maxTagCount") ? newProps.maxTagCount : "responsive";
      if (!tooltip) {
        newProps.maxTagPlaceholder = (omittedValues) => {
          const len = omittedValues == null ? void 0 : omittedValues.length;
          if (len) {
            const tipTitle = /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: { padding: "6px 8px", wordBreak: "break-all", whiteSpace: "normal" },
                onClick: (e) => e.stopPropagation(),
                onMouseDown: (e) => e.stopPropagation()
              },
              omittedValues.map((v) => v.label).join()
            );
            return /* @__PURE__ */ import_react.default.createElement(
              import_antd.Tooltip,
              {
                overlayInnerStyle: { padding: 0 },
                getTooltipContainer: (target) => {
                  var _a;
                  return ((_a = target.offsetParent) == null ? void 0 : _a.parentElement) || document.body;
                },
                title: tipTitle,
                mouseEnterDelay: 0.2
              },
              /* @__PURE__ */ import_react.default.createElement("span", { style: { display: "inline-flex", alignItems: "center", maxWidth: "100%" } }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nowrap", style: { flex: 1 } }, omittedValues[0].label), len > 1 ? `,  + ${len - 1} ...` : ``)
            );
          }
          return null;
        };
      }
    }
    if (newProps.maxTagCount === "responsive") {
      newProps.className = import_util.iup.classNames(newProps.className, "help-responsive");
    }
    if (!newProps.hasOwnProperty("popupMatchSelectWidth")) {
      newProps.popupMatchSelectWidth = false;
    }
    newProps.dropdownStyle = { maxWidth: "50vw", ...newProps.dropdownStyle };
    if (modal && !disabled) {
      if (!input) {
        newProps.onClick = function() {
          ref.current.openHelp();
        };
      } else {
        newProps.onDoubleClick = (e) => {
          if ((onDoubleClick == null ? void 0 : onDoubleClick(e, ref.current)) !== false) {
            ref.current.openHelp();
          }
        };
      }
      newProps.suffixIcon = /* @__PURE__ */ import_react.default.createElement(
        OpenHelpIcon,
        {
          buttonMode: void 0,
          request: dataRequest,
          contentParams: { ...props, ...contentParams },
          modalProps,
          selectedRequest,
          onBeforeOpen,
          outRef: ref,
          helpContent,
          style: iconStyle
        }
      );
      newProps.className = "help-with-icon";
    }
    const getDropColumns = () => {
      const {
        userCodeField,
        valueField: vf,
        labelField: lf
      } = (getHelpInfo == null ? void 0 : getHelpInfo()) || { userCodeField: defaultUserCodeField, valueField, labelField };
      const dropColumns = (userCodeField == null ? void 0 : userCodeField.split(",").map((f) => {
        const [key, width] = f.trim().split(":");
        return { dataIndex: key, width };
      })) || [{ dataIndex: vf }, { dataIndex: lf }];
      if (userCodeFieldWithLabel && !dropColumns.find(({ dataIndex }) => dataIndex === lf)) {
        dropColumns.push({ dataIndex: lf });
      }
      return dropColumns;
    };
    newProps.tooltip = tooltip;
    newProps.notFoundContent = state.loading ? /* @__PURE__ */ import_react.default.createElement("div", { style: { minHeight: 28 } }) : loadByFocus && innerRef.current.loaded ? /* @__PURE__ */ import_react.default.createElement(import_antd.Empty, { image: import_antd.Empty.PRESENTED_IMAGE_SIMPLE }) : null;
    if (isTree) {
      delete newProps.filterOption;
      delete newProps.popupMatchSelectWidth;
      delete newProps.mode;
      newProps.multiple = multiple;
      newProps.filterTreeNode = false;
      const treeData = import_util.iup.deepCopy(state.options);
      import_util.iup.loopChildren({ children: treeData }, (d) => {
        const [value, label] = [getValue(d), getValue(d, "label")];
        d.value = value;
        d.label = label;
        d.key = value;
      });
      return /* @__PURE__ */ import_react.default.createElement(import_baseComponent.Select, { defaultOpen: newProps.autoFocus && loadByFocus, isTree: true, ...newProps, data: treeData });
    }
    return /* @__PURE__ */ import_react.default.createElement(import_baseComponent.Select, { ...newProps }, state.options.map((d) => {
      const [value, label] = [getValue(d), getValue(d, "label")];
      const [title, cls, whiteSpace] = nowrap ? [label, "nowrap", "nowrap"] : ["", "", "normal"];
      return /* @__PURE__ */ import_react.default.createElement(import_baseComponent.Select.Option, { key: value, value, label, "data-origin": d.origin || d }, /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "flex", alignItems: "center", minHeight: 22 }, title }, getDropColumns().map(({ dataIndex: c, width }, index) => {
        let s = { flex: 1 }, key = c, content = "";
        if (import_util.iup.isFunction(c)) {
          key = index;
          content = c(d);
        } else {
          s = width ? { width } : s;
          content = d[c] ?? content;
        }
        return /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            key,
            className: cls,
            style: { ...s, marginRight: 5, whiteSpace, wordBreak: "break-all", lineHeight: 1 }
          },
          content
        );
      })));
    }));
  }
  return /* @__PURE__ */ import_react.default.createElement(
    OpenHelpIcon,
    {
      buttonMode,
      request: dataRequest,
      contentParams: { ...props, ...contentParams },
      modalProps,
      selectedRequest,
      onBeforeOpen,
      outRef: ref,
      helpContent,
      style: iconStyle
    }
  );
};
BaseHelp.Header = import_baseContent.Header;
BaseHelp.Footer = import_baseContent.Footer;
BaseHelp.MultipleButtons = import_baseContent.MultipleButtons;
function Help({ type = "MultipleHelp", closeReturn, ...props }) {
  const [Tmp, defaultProps] = (0, import_util.getRegisterComponentWithProps)(type);
  const tmpRef = (0, import_react.useRef)();
  (0, import_react.useEffect)(() => {
    var _a;
    const api = tmpRef.current.getApi();
    (_a = api.openHelp) == null ? void 0 : _a.call(api);
    return api.getHelper().observer.subscribe((param) => {
      closeReturn(param || {});
    }, "afterClose");
  }, []);
  return /* @__PURE__ */ import_react.default.createElement(Tmp, { ...defaultProps, ...props, ref: tmpRef, style: { display: "none", width: 0, height: 0 } });
}
function openHelp(config) {
  return new Promise((resolve) => {
    const div = document.createElement("div");
    document.body.appendChild(div);
    const root = (0, import_client.createRoot)(div);
    const helpProps = {
      ...config,
      closeReturn({ result }) {
        resolve(result);
      },
      modalProps: {
        ...config.modalProps,
        afterClose() {
          setTimeout(() => {
            root.unmount();
            if (div.parentNode) {
              div.parentNode.removeChild(div);
            }
          });
        }
      }
    };
    root.render(/* @__PURE__ */ import_react.default.createElement(Help, { ...helpProps }));
  });
}
import_util.iup.registerExternal({ openHelp });
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  BaseHelp,
  HelpContext
});
